#!/usr/bin/env python3
UserName = 'tango'
PassWord = 'Password'
TryTimes = 3
while TryTimes > 0: # 这里的>0可以省略
    InputUserName = input('Please input your name ,and Press Enter: ')
    InputPassWord = input('Please input your pass ,and Press Enter: ')
    if UserName == InputUserName and PassWord == InputPassWord:
        print('Login Successed.')
        TryTimes = 0 # 这里直接break就好
    else:
        print('Login Failed. Username not found or Password Error.')
        TryTimes -= 1
        print('You get last ',TryTimes,' times to retry')
        if TryTimes == 0:
            print('You have exceeded the max number of attempts allowed,now exit')
